package scjp.preparation.datastructure;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

public class TestIterationsOverList {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		List<String> l = new ArrayList<String>();
		l.add("Yev");
		l.add("Dina");
		for (Iterator<String> iter = l.iterator(); iter.hasNext();) {
			System.out.println(iter.next());
		}

		ListIterator<String> i = l.listIterator();

		for (ListIterator<String> iter = l.listIterator(); iter.hasPrevious();) {
			System.out.println(iter.previousIndex());
		}

		Set<Integer> set = new TreeSet<Integer>();

		Map<Integer, String> map = new HashMap<Integer, String>();
		map.put(5, "25");
		map.put(10, "10");
		map.put(3, "3");
		map.put(5, "5");
		System.out.println(map);

		Deque<Integer> deque = new LinkedList<>();
		deque.add(10);
		deque.add(20);
		deque.peek();
		deque.peek(); // #1
		System.out.println(deque);

		Map<String, String> map3 = new LinkedHashMap<>();
		Map<String, String> map2 = new IdentityHashMap<>();
		
		String hello = "hello";
		String world = "world";
		StringBuffer helloWorld = new StringBuffer(hello + world);
		List<String> list =
		Arrays.asList(hello, world, helloWorld.toString());
		System.out.println(list);
		helloWorld.append("!");
		System.out.println(list);
//		System.out.println(list);
		
		String s = new String("5");
		System.out.println(1.0+11.0+s+(1.0+10.5));
		
		int a = 7, b = 10;
		System.out.printf("no:%2$s and %1$s", a, b);
		System.out.printf("\nno:2$s and 1$s", a, b);
		System.out.println("\n");
		
		String quote = "aba*abaa**aabaa***";
		String [] words = quote.split("a\\**", 10);
		for (String word : words) {
		System.out.println(word);
		
		}
		}


	public static <T> Collection<?> asList2(T... elements) {
		ArrayList<T> temp = new ArrayList<>();
		for (T element : elements) {
			temp.add(element);
		}
		return temp;
	}

}
